package com.inviscidlabs.schooled;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class FragmentSchooledHome extends Fragment {
	
//View Variables
	private Button addGrade;
	private Button bareMinimum;
	private Button viewGrades;
	
//Misc Variables
	private HomeItemListener homeItemListener;
	
	
//===================ON CREATE VIEW======================	
	 @Override
	 public View onCreateView(LayoutInflater inflater, ViewGroup container,
	      Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.screen_schooledhome, container);
		OnClickListener oCL= new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				homeItemListener.buttonClicked(v.getId());
			}
		};
		bareMinimum=(Button) v.findViewById(R.id.schooled_btn_bareminimum); bareMinimum.setOnClickListener(oCL);
		addGrade=(Button) v.findViewById(R.id.schooled_btn_addGrade); addGrade.setOnClickListener(oCL);
		viewGrades=(Button) v.findViewById(R.id.schooled_btn_viewgrades); viewGrades.setOnClickListener(oCL);
		return v;
		 }
	 
//=========Interface for HomeItemListener=============
	 public interface HomeItemListener{
		 public void buttonClicked(int bId);
	 }
	 
//=============ON ATTACH==============
	 @Override
	  public void onAttach(Activity activity) {
	    super.onAttach(activity);
	    if (activity instanceof HomeItemListener){
	    	homeItemListener=(HomeItemListener) activity;
	    }
	    else {
	    	throw new ClassCastException(activity.toString() +"must implement HomeItemListener");
	    }
	 }



}
